/* Copyright (C) 2010 CodeFutures Corporation

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */


#ifndef LOGGER_H_
#define LOGGER_H_

#include <string>
#include <map>

#define LOG_LEVEL_NONE  0
#define LOG_LEVEL_TRACE 1
#define LOG_LEVEL_DEBUG 2
#define LOG_LEVEL_INFO  3
#define LOG_LEVEL_WARN  4
#define LOG_LEVEL_ERROR 5

#define DEBUG_LOGGER
/*
 *  logger4cpp - Simple C++ Logger
 *
 *  Copyright (C) 2011 CodeFutures Corporation. All rights reserved.
 */

using namespace std;

namespace logger4cpp {

class Logger {
private:

    // logger name
	string name;

	// logger level
	bool isTrace;
    bool isDebug;
    bool isInfo;
    bool isWarn;
    bool isError;

	// file handle
	static FILE *file;

    static long timeStart;

	static long lineCount;

private:

	void log(const char *level, const char *message);
	static string getTimestamp();

public:
	Logger(string name, int logLevel);
	virtual ~Logger();

	bool isTraceEnabled();
	bool isDebugEnabled();
	bool isInfoEnabled();
	bool isWarnEnabled();
	bool isErrorEnabled();

	void trace(string message);
	void debug(string message);
	void info(string message);
	void warn(string message);
	void error(string message);

	void trace(const char *message);
	void debug(const char *message);
	void info(const char *message);
	void warn(const char *message);
	void error(const char *message);
};

} // namespace

#endif /* LOGGER_H_ */
